#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define MAXN 100005

int T,n;

ll ans;

int a[MAXN];

ll sum = 0;

int last[2] = {-1,-1};

int getcolor(int index,int x){
    return ((x >> (index-1)) & 1);
}

void check(int x){
    last[0] = last[1] = -1;
    sum = 0;
    for(int i = 1;i <= n;i++){
        //printf("%d %d %d\n",i,x,getcolor(i,x));
        int k = ((x >> (i-1)) & 1);
        if(last[k] == a[i]){
            sum += a[i];
        }
        last[k] = a[i];
    }
    ans = max(ans,sum);
}

int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        ans = 0;
        for(int i = 1;i <= n;i++){
            scanf("%d",&a[i]);
        }
        for(int i = 0;i < (1 << n);i++){
            check(i);
        }
        printf("%lld\n",ans);
    }


	return 0;
}
